﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace ZoomBar2007
{
    public class ZoomBarStripItem : ToolStripItem
    {
        private ZoomBarCommon m_zoomBarCommon;

        public ZoomBarStripItem()
        {
            m_zoomBarCommon = new ZoomBarCommon(this);
            m_zoomBarCommon.Bounds = this.Bounds;
            m_zoomBarCommon.PositionChanged += new EventHandler(m_zoomBarCommon_PositionChanged);

        }

        void m_zoomBarCommon_PositionChanged(object sender, EventArgs e)
        {
            OnPositionChanged();
        }

        public event EventHandler PositionChanged;

        private void OnPositionChanged()
        {
            if (PositionChanged != null)
                PositionChanged(this, EventArgs.Empty);
        }

        public double Position
        {
            get { return m_zoomBarCommon.Position; }
            set { m_zoomBarCommon.Position = value; }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            m_zoomBarCommon.OnPaint(e);
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            m_zoomBarCommon.OnMouseDown(e);
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            m_zoomBarCommon.OnMouseUp(e);
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            m_zoomBarCommon.OnMouseMove(e);
        }


        protected override void OnBoundsChanged()
        {
            base.OnBoundsChanged();
            m_zoomBarCommon.Bounds = this.Bounds;
            m_zoomBarCommon.OnResize(EventArgs.Empty);
        }


    }
}
